<template>
  <div class="coupons" @click="selectCoupons(data)">
    <div class="coupons-info">
      <p class="coupons-name">{{data.name}}</p>
      <p class="coupons-end-time">使用时间: {{getStartDate}} 至 {{getEndDate}}</p>
    </div>
    <img class="coupons-interval" src="../../static/images/coupons-bg.png" mode="scaleToFill" alt="">
    <div class="coupons-amount-info">
      <p class="coupons-amount">
        <span class="amount-num">{{data.money}}</span>
        <span class="amount-unit">元</span>
      </p>
      <p class="coupons-condition">满{{data.condition}}元可用</p>
      <div class="coupons-btn">去使用</div>
    </div>
  </div>
</template>

<script>
  import {
    getDate
  } from '@/utils/index'
  export default {
    props: ['data', 'selectCoupons'],
    computed: {
      getStartDate() {
        return getDate(this.data.use_start_time)
      },
      getEndDate() {
        return getDate(this.data.use_end_time)
      },
    }
  };

</script>

<style lang="less">
  .coupons {
    display: flex;
    align-items: center;
    border-radius: 5px;
    overflow: hidden;

    .coupons-interval {
      height: 100px;
      width: 13px;
    }

    .coupons-info {
      height: 100px;
      flex: 1;
      padding: 25px 15px;
      background: #fff;

      .coupons-name {
        margin-bottom: 22px;
        font-size: 18px;
        line-height: 1em;
        color: #606060;
      }

      .coupons-end-time {
        font-size: 10px;
        color: #A0A0A0;
        line-height: 1em;
      }
    }

    .coupons-amount-info {
      width: 128px;
      height: 100px;
      display: flex;
      align-items: center;
      justify-content: center;
      flex-direction: column;
      background: #fff;

      .coupons-amount {
        display: flex;
        align-items: flex-end;
        text-align: center;
      }

      .amount-num {
        font-size: 24px;
        color: #EE7559;
        line-height: 1em;
      }

      .amount-unit {
        font-size: 13px;
        color: #EE7559;
      }

      .coupons-condition {
        margin-top: 4px;
        text-align: center;
        font-size: 12px;
        color: #EE7559;
      }

      .coupons-btn {
        width: 65px;
        height: 22px;
        background: none;
        border: 1rpx solid #EE7559;
        border-radius: 11px;
        text-align: center;
        line-height: 22px;
        color: #EE7559;
        font-size: 12px;
        margin-top: 6px;
      }
    }
  }

</style>
